package com.action;
import java.util.ArrayList;
import java.util.List;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.dao.SearchProduct;

import entities.Product;

/**
 * Servlet implementation class OrderCart
 */
@WebServlet("/OrderCart")
public class OrderCart extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public OrderCart() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session = request.getSession();
		Product p = new Product();
		//List<Product> list = new ArrayList<Product>();
		//List productids = (List)session.getAttribute("Productids");
		/*for(Object s: productids)
		{
			p = SearchProduct.searchByID(s.toString());
			list.add(p);
		}*/
		//session.setAttribute("Products", list);
		if(session.getAttribute("Userid")==null)
		{
			response.sendRedirect("try.jsp");
		}
		String pid = request.getParameter("Productid");
		p = SearchProduct.searchByID(pid);
		session.setAttribute("Product", p);
		//response.sendRedirect("ordercart.jsp");
		/*session.setAttribute("show", "ordercart.jsp");
		request.getRequestDispatcher("try.jsp").forward(request, response);*/
	}

}
